package logic

import (
	"context"
	"errors"
	"gitignore/models/mysql"

	"gitignore/gitignorerpc/gitignorerpc"
	"gitignore/gitignorerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectionDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollectionDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectionDelLogic {
	return &CollectionDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CollectionDelLogic) CollectionDel(in *gitignorerpc.CollectionDelRequest) (*gitignorerpc.CollectionDelResponse, error) {
	// todo: add your logic here and delete this line
	var collect mysql.Collection

	err := collect.FindCollectaByDel(mysql.DB, in.CollectTime)
	if err != nil {
		return nil, errors.New("取消收藏失败")
	}
	return &gitignorerpc.CollectionDelResponse{}, nil
}
